package com.checkCode.controller;

/**
 * @author 大忽悠
 * @create 2023/2/9 20:56
 */
import com.checkCode.entity.dto.CheckCodeResultDto;
import com.checkCode.entity.vo.CheckCodeParamsVo;
import com.checkCode.service.ICheckCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 大忽悠
 * @create 2022/9/15 11:09
 */
@Validated
@RestController
@RequestMapping("/checkCode")
@RequiredArgsConstructor
@Api(tags="验证码服务")
public class CheckCodeController {
    private final ICheckCodeService checkCodeService;

    @ApiOperation(value="生成验证码")
    @PostMapping(value = "/code")
    public CheckCodeResultDto generateCode(CheckCodeParamsVo checkCodeParamsVo){
        return checkCodeService.generate(checkCodeParamsVo);
    }

    @ApiOperation(value="校验验证码")
    @PostMapping(value = "/verify")
    public Boolean verify(String key, String code){
       return checkCodeService.verify(key,code);
    }
}
